//
//  Text_DateFormatter.swift
//  Demo_01
//
//  Created by apple on 2020/7/21.
//  Copyright © 2020 Joseph. All rights reserved.
//

import SwiftUI

// 对文本中的日期内容进行格式化。
struct Text_DateFormatter: View {
    var now = Date()
    static let dateFormatter: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateStyle = .long
        return formatter
    }()

    var body: some View {
        Text("The time is: \(now, formatter: Self.dateFormatter)")
            .font(.title)
            .padding()
    }
}

struct Text_DateFormatter_PreViews: PreviewProvider {
    static var previews: some View {
        Text_DateFormatter()
    }
}
